<#--noinspection ALL-->
<template>
      <el-form ref="form" :model="form" <#if isNotNullColumns??>:rules="rules"</#if> size="small" label-width="80px">
        <#if columns??>
            <#list columns as column>
                <#if column.formShow>
                <el-form-item label="<#if column.remark != ''>${column.remark}<#else>${column.changeColumnName}</#if>"<#if column.istNotNull> prop="${column.changeColumnName}"</#if>>
                    <#if column.formType = 'Input'>
                    <el-input v-model="form.${column.changeColumnName}" style="width: 370px;" />
                    <#elseif column.formType = 'Textarea'>
                    <el-input v-model="form.${column.changeColumnName}" :rows="3" type="textarea" style="width: 370px;" />
                    <#elseif column.formType = 'Radio'>
                    <#if (column.dictName)?? && (column.dictName)!="">
                    <el-radio v-model="form.${column.changeColumnName}" v-for="item in dict.${column.dictName}" :key="item.id" :label="item.value">{{ item.label }}</el-radio>
                    <#else>
                        未设置字典，请手动设置 Radio
                    </#if>
                    <#elseif column.formType = 'Select'>
                    <#if (column.dictName)?? && (column.dictName)!="">
                    <el-select v-model="form.${column.changeColumnName}" filterable placeholder="请选择">
                    <el-option
                        v-for="item in dict.${column.dictName}"
                        :key="item.id"
                        :label="item.label"
                        :value="item.value" />
                    </el-select>
                    <#else>
                    未设置字典，请手动设置 Select
                    </#if>                   
                    <#elseif column.formType = 'Picture'>
                     <!--  图片选择框  -->
                    <pictureUpload v-model="form.${column.changeColumnName}" />
                    <#assign hasPic=true/>              
                    <#else>
                    <el-date-picker v-model="form.${column.changeColumnName}" type="datetime" style="width: 370px;" />
                    </#if>
                </el-form-item>
                </#if>
            </#list>
        </#if>
        </el-form>
</template>
<script>
import { form } from '@crud_my/crud'
let components={}
 <#if hasPic??> 
 import pictureUpload from '@/components/upload/pictureUpload'
 components['pictureUpload']=pictureUpload
 <#assign hasComponent=true/>  
 </#if>

export default {
<#if hasComponent??> 
  components: components,
 </#if>
  mixins: [form()],
  <#if hasDict>
  dicts: [<#if hasDict??><#list dicts as dict>'${dict}'<#if dict_has_next>, </#if></#list></#if>],
  </#if>
  data() {
    return {
      form:this.crud.form,
      rules: {
        <#if isNotNullColumns??>
        <#list isNotNullColumns as column>
        <#if column.istNotNull>
        ${column.changeColumnName}: [
          { required: true, message: '<#if column.remark != ''>${column.remark}</#if>不能为空', trigger: 'blur' }
        ]<#if column_has_next>,</#if>
        </#if>
        </#list>
        </#if>
      }
    }
  }
}
</script>
